<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="shortcut icon" href="../../static/asserts/images/login_logo.png" />

    <!-- Style Sheet-->
    <link rel='stylesheet' id='bootstrap-css-css'  href='../../static/asserts/css/bootstrap5152.css?ver=1.0' type='text/css' media='all' />
    <link rel='stylesheet' id='responsive-css-css'  href='../../static/asserts/css/responsive5152.css?ver=1.0' type='text/css' media='all' />
    <link rel='stylesheet' id='pretty-photo-css-css'  href='../../static/asserts/js/prettyphoto/prettyPhotoaeb9.css' type='text/css' media='all' />
    <link rel='stylesheet' id='main-css-css'  href='../../static/asserts/css/main.css' type='text/css' media='all' />

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="../../static/asserts/js/html5.js"></script></script>
    <![endif]-->
</head>
<body>
<!-- Start of Header -->
<div th:replace="commons/bar::topbar"></div>
<!-- End of Header -->

<!-- Start of Search Wrapper -->
<div class="search-area-wrapper">
    <div class="search-area container">
        <h3 class="search-header">来 ! 发 现 !</h3>
        <p class="search-tag-line">If you have any question you can ask below or enter what you are looking for!</p>

        <form action="/search" id="search-form" class="search-form clearfix" method="get"  th:action="@{/search}" autocomplete="off">
            <select name="way" class="search-class">
                <option  value="title" class="select-opt">帖子</option>
                <option  value="author" class="select-opt">作者</option>
                <!--                                             <option  value="levelmore">等级大于</option>-->
                <!--                                             <option  value="levelless">等级小于</option>-->
            </select>
            <input class="search-term required" type="text" id="s" name="searchname" placeholder="搜索帖子" title="搜索帖子" />
            <input class="search-btn" type="submit" value="搜索" />
            <div id="search-error-container"></div>
            <div style="color: #46A3FF; font-size: 17px; text-align: center; margin-top: 40px; margin-bottom: 0px">
                <b th:text="${res}" th:if="${not #strings.isEmpty(res)}"></b>
                <b th:text="${session.msg}" th:if="${not #strings.isEmpty(session.msg)}"></b>
            </div>
        </form>

    </div>
</div>
<!-- End of Search Wrapper -->


<!-- Start of Page Container -->
<div class="page-container" th:if="${#strings.isEmpty(res)}">
    <div class="container">
        <div class="row">

            <!-- start of page content -->
            <div class="span8 page-content">

                <article class=" type-page  hentry clearfix">

                    <h1 class="post-title" th:text="${article.title}"></h1>
<!--                    文章头部信息：标题，作者，最后更新日期，导航-->
                    <div class="profile" style="width: 50px;float: left;transform: translateY(-5px);margin-left: 0;margin-right: 5px">
                        <img href="@{/otheruserspace/}+${article.author}" alt="头像" th:src="@{/showImg/}+${session.otherusrheadImg}" style="border-radius:50%" height="50" width="50"><br>
                    </div>
                    <hr>
                    <div class="article-info">
                        <h4>作者:  <a th:href="@{/otheruserspace/}+${article.author}" th:text="${article.author}"></a> 标签:  <a  href="" th:text="${article.categoryName}"></a></h4>
                    </div>
                    <hr>
                    <div id="doc-content">
                        <textarea style="display:none;" placeholder="markdown" th:text="${article.content}"></textarea>

                    </div>
                    <div class="like-btn">
                        <button class="like-it" style="height: 30px"  th:onclick="'javascript:regist(\''+${0}+'\',\''+${article.id}+'\')'" th:text="${article.likes}" id="like0">66</button>
                        <a href="#respond"><button class="diy-btn " style="margin-right: 0;margin-bottom: 0">回复</button></a>
<!--                        <a href="" download><button class="diy-btn "  >下载文件</button></a>-->
                        <form th:action="@{/delAtc/}+${article.id}" method="post" style="display:inline" th:if="${session.level}==0">
                            <input type="hidden" name="_method" value="delete" />
                            <button type="submit" class="diy-btn " style="margin-right: 0;margin-bottom: 0">删除帖子</button>
                        </form>

                    </div>


                    <div th:each= "reply:${replys}">
                        <div >
                            <div th:each="user:${users}">
                                <div th:if="${ reply.content != null && user.id eq reply.userid}" class="comment-username">
                                    <hr>
                                    <div class="profile" style="width: 30px;float: left;transform: translateY(-7px);margin-right: 5px">
                                        <img th:href="@{/otheruserspace/}+${user.username}" alt="头像" th:src="@{/showRpyImg/}+${user.id}" style="border-radius:50%" height="30" width="30"><br>
                                    </div>
                                    <h4 ><a th:href="@{/otheruserspace/}+${user.username}" th:text="${user.username}">回复用户名</a></h4>
                                    <blockquote>
                                        <p th:text="${reply.content}" th:id="${reply.id}">回复</p>
                                    </blockquote>
                                    <div class="like-btn">
                                        <button class="like-it" style="height: 30px"  th:onclick="'javascript:regist(\''+${reply.id}+'\',\''+${article.id}+'\')'" th:text="${reply.likes}" th:id="@{like} + ${reply.id}">66</button>
                                        <button class="diy-btn" formaction=""  th:onclick="'javascript:document.getElementById(\'comment-area' + ${reply.id}+'\').hidden=!(document.getElementById(\'comment-area' + ${reply.id}+'\').hidden)'">回复</button>
                                        <span th:each = "reply1:${reply1s}" >
                                            <a th:href="@{#} + ${reply1.replyid}"><button class="diy-btn " formaction=""  th:if = "${reply1.replyid eq reply.id}" th:text="${reply1.username} + 回复了此贴" ></button></a>
                                        </span>
<!--                                        <a href="" download><button class="diy-btn">下载文件</button></a>-->
                                        <form th:action="@{/delReply/}+${reply.id}" method="post" style="display:inline" th:if="${session.level}==0">
                                            <input type="hidden" name="_delMethod" value="del" />
                                            <button type="submit" class="diy-btn " style="margin-right: 0;margin-bottom: 0">删除回复</button>
                                        </form>
                                    </div>
                                    <form th:action="@{/reply/r} + ${reply.id}" method="post" >
                                        <input name="articleid"
                                               th:value="${article.id}"
                                               th:hidden="hidden"/>
                                        <br>
                                        <div th:id="@{comment-area} + ${reply.id}" hidden="hidden">
                                            <textarea class="span8" name="rContent" th:id = "${reply.id}"  cols="20" rows="5"></textarea>
                                            <input class="btn" name="submit" type="submit"  value="发布" >
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </article>
                <hr>
                <div id="respond">

                    <h3>回复帖子</h3>

                    <form th:action="@{/reply/a} + ${article.id}" method="post" id="commentform">
                        <input name="articleid"
                               th:value="${article.id}"
                               th:hidden="hidden"/>
                        <div>
                            <label for="comment">内容</label>
                            <textarea class="span8" name="rContent" id="comment" cols="58" rows="10"></textarea>
                        </div>

                        <div>
                            <input class="btn" name="submit" type="submit" id="submit" value="发布">
                        </div>

                    </form>

                </div>
            </div>
            <!-- end of page content -->


            <!-- start of sidebar -->
            <aside class="span4 page-sidebar">

                <section class="widget">
                    <div class="support-widget">
                        <a th:href="@{/mk}">发布帖子</a>
                    </div>
                </section>


                <section class="widget">
                    <h3 class="title">最热帖子</h3>
                    <ul class="articles">
                        <li class="article-entry standard" th:each="course:${sidebar}">
                            <h4><a href="single.html" th:text="${course.title}==null?${course.id}:${course.title}" th:href="@{/showBlog/}+${course.id}"></a></h4>
                            <span class="" th:text="${course.dateformat}==null?'暂无日期':${course.dateformat}"></span>
                            <span class=""><a th:href="@{/otheruserspace/}+${course.author}" th:text="${course.author}" ></a></span>
                            <span class=""><a th:text="${course.categoryName}"></a></span>
                            <span class="" th:text="等级要求+${course.level}"></span>
                            <span class="like-count" th:text="${course.likes}" ></span>
                        </li>
                    </ul>
                </section>
            </aside>
            <!-- end of sidebar -->
        </div>
    </div>
</div>
<!-- End of Page Container -->

<a href="#top" id="scroll-top"></a>

<link rel="stylesheet" th:href="@{/editormd/css/editormd.preview.css}" />
<script th:src="@{/editormd/lib/jquery.min.js}"></script>
<script th:src="@{/editormd/lib/marked.min.js}"></script>
<script th:src="@{/editormd/lib/prettify.min.js}"></script>
<script th:src="@{/editormd/lib/raphael.min.js}"></script>
<script th:src="@{/editormd/lib/underscore.min.js}"></script>
<script th:src="@{/editormd/lib/sequence-diagram.min.js}"></script>
<script th:src="@{/editormd/lib/flowchart.min.js}"></script>
<script th:src="@{/editormd/lib/jquery.flowchart.min.js}"></script>
<script th:src="@{/editormd/lib/editormd.min.js}"></script>

<script type="text/javascript">
    var testEditor;
    $(function () {
        testEditor = editormd.markdownToHTML("doc-content", {//注意：这里是上面DIV的id
            htmlDecode: "style,script,iframe",
            emoji: true,
            taskList: true,
            tocm: true,
            tex: true, // 默认不解析
            flowChart: true, // 默认不解析
            sequenceDiagram: true, // 默认不解析
            codeFold: true
        });
    });
</script>


<!-- script -->
<script type='text/javascript' src='../../static/asserts/js/jquery-1.8.3.min.js'></script>
<script type='text/javascript' src='../../static/asserts/js/jquery.easing.1.34e44.js?ver=1.3'></script>
<script type='text/javascript' src='../../static/asserts/js/prettyphoto/jquery.prettyPhotoaeb9.js?ver=3.1.4'></script>
<script type='text/javascript' src='../../static/asserts/js/jquery.liveSearchd5f7.js?ver=2.0'></script>
<script type='text/javascript' src='../../static/asserts/js/jflickrfeed.js'></script>
<script type='text/javascript' src='../../static/asserts/js/jquery.formd471.js?ver=3.18'></script>
<script type='text/javascript' src='../../static/asserts/js/jquery.validate.minfc6b.js?ver=1.10.0'></script>
<script type='text/javascript' src='../../static/asserts/js/custom5152.js?ver=1.0'></script>
<script type="text/javascript">
function regist(replyId,articleId) {
    var localurl="http://" + window.location.host + "/Like/doLike";
    $.ajax({
        type:"post",
        async:false,
        // contentType: "application/json",
        data:{replyId,articleId
        },
        dataType:"json",
        url:localurl,
        success:function(data){
            document.getElementById("like" + replyId).innerText=data.likes;
        }
    });
}
function reply_a0(rContent,articleId) {
    var localurl="http://" + window.location.host + "/reply/a" + articleId;
    $.ajax({
        type:"post",
        async:false,
        // contentType: "application/json",
        data:{rContent,articleId
        },
        dataType:"json",
        url:localurl,
        success:function(data){
            alert(data.msg)
            //document.getElementById("like" + replyId).innerText=data.likes;
        }
    });
}
</script>
</body>
</html>